Imports MIMS.WRS.Entities
Imports MIMS.WRS.Business
Imports MyFramework

Public Class BOService
    Public Shared Sub CheckOutOfDateReservedQuantity()
        Try
            Dim items As CustomerProductCollection = CustomerProductService.GetCustomerProducts(CustomerProductColumns.UserID, OrderDirection.ASC)
            For Each custPro As CustomerProduct In items
                If custPro.ReservedDate <> Nulls.NullDate AndAlso DateTime.Now.Subtract(custPro.ReservedDate).TotalDays > custPro.NumberOfDay Then
                    custPro.ReservedDate = Nulls.NullDate
                    custPro.ReservedQty = Nulls.NullInteger
                    CustomerProductService.UpdateCustomerProduct(custPro)
                    Logger.Info("Found and succesful updated reserved quantity for customter " + custPro.LoginName)
                End If
            Next

        Catch ex As Exception
            Logger.Error("Failed to run CheckOutOfDateReservedQuantity", ex)
        End Try
    End Sub
End Class
